package com.play.ballen.me.vm

import androidx.lifecycle.MutableLiveData
import com.play.ballen.me.entity.InvitePosterInfo
import com.play.ballen.me.entity.TeamInfo
import com.play.ballen.network.ApiRepository
import com.play.ballen.network.BallenRxHelper
import com.yuven.appframework.network.RxSchedulerHelper
import com.yuven.appframework.util.addToDisposable
import com.yuven.baselib.component.viewmodel.BaseViewModel
import com.yuven.baselib.utils.Logger

class InvitePosterVM : BaseViewModel() {

    private val model = ApiRepository()
    val invitePosterInfo = MutableLiveData<InvitePosterInfo>()

    fun invitePoster() {
        model.invitePoster()
            .onErrorResumeNext(BallenRxHelper.HttpErrorHandleFunc())
            .compose(BallenRxHelper.transformResponse())
            .compose(RxSchedulerHelper.io_main())
            .subscribe({
                Logger.i("InvitePosterVM.invitePoster success")
                invitePosterInfo.value = it
            }, { throwable ->
                toastLiveData.value = throwable.message
                Logger.i("InvitePosterVM.invitePoster error,msg = ${throwable.message}")
            }).addToDisposable(compositeDisposable)
    }

}